import request from '@/utils/axios';
import appName from "../appName"
import window from "cytoscape/src/window";

//新契约任务查询
export function page(params) {
    return request({
        url: appName.TASK + '/nb/task/pageinfo',
        method: 'post',
        data: params
    })
}

//重置任务等级
export function nbTaskResetLvl(lvl, taskNos) {
    return request({
        url: appName.TASK + `/nb/task/lvl/reset`,
        method: 'post',
        data: {lvl: lvl, taskNos: taskNos}
    })
}

//查询核保任务
export function findNbHeBaoList(policyholderno, insuredno) {
    return request({
        url: appName.TASK + `/nb/task/findNbHeBaoList?insuredno=${insuredno}&policyholderno=${policyholderno}`,
        method: 'get',
    })
}
//查询核保任务
export function checkLockAndModify(applnum) {
    return request({
        url: appName.TASK + `/nb/task/checkLockAndModify?applnum=`+applnum,
        method: 'get',
    })
}

//导出再保信息
export function exportZBInfoWord(type, casenos,that) {
    setTimeout(() => {
            that.$store.dispatch('loading/CHANGE_LOADING', false);
        }, 3000
    )
    request(
        {
            url: appName.TASK + `/nb/task/exportZBReportWord?type=${type}&casenos=${casenos}`,
            responseType: 'blob',
            method: 'get',
        }
    ).then(res => {
        that.$store.dispatch('loading/CHANGE_LOADING',false);
        let fileName = "再保资料.zip";
        // 获取文件名

        // 兼容ie11
        if (window.navigator.msSaveOrOpenBlob) {
            try {
                const blobObject = new Blob([res.data]);
                window.navigator.msSaveOrOpenBlob(blobObject, fileName);
            } catch (e) {
                console.log(e);
            }
            return;
        }
        let url = window.URL.createObjectURL(new Blob([res.data]));
        let link = document.createElement('a');
        link.style.display = 'none';
        link.href = url;
        link.setAttribute('download', fileName);
        document.body.appendChild(link);
        link.click();
    })
}